<template>
	<view :class="isShowEmptyData ? 'content-empty' : 'content'">
		<view class="serve">
			<view v-if="isShowServeInfo" class="serve_info">
				<view class="header header_more">
					<view class="horizontal">
						<view class="line"></view>
						<view class="serve_info_contact">联系方式</view>
					</view>
					<view class="serve_info_close" @click="isShowServeInfo = false"><image src="../../static/close_icon2.png" mode="widthFix"></image></view>
				</view>
				<view class="line"></view>
				<view class="serve_info_list">
					<view class="serve_info_item">
						<view class="serve_info_item_image"><image src="../../static/wechat.png" mode="widthFix"></image></view>
						<view class="serve_info_item_contactNumber">12345678901</view>
					</view>
					<view class="serve_info_item">
						<view class="serve_info_item_image"><image src="../../static/phone.png" mode="widthFix"></image></view>
						<view class="serve_info_item_contactNumber">15596857412</view>
					</view>
					<view class="serve_info_item">
						<view class="serve_info_item_image"><image src="../../static/hotline.png" mode="widthFix"></image></view>
						<view class="serve_info_item_contactNumber">400-6369-798</view>
					</view>
				</view>
			</view>
			<view v-else class="serve_image" @click="isShowServeInfo = true"><image src="../../static/serve.png" mode="widthFix"></image></view>
		</view>

		<view v-if="isShowDialog" class="dialog">
			<image class="dialog_banner" src="../../static/dialog_banner.png" mode="widthFix"></image>
			<image class="dialog_close" src="../../static/close_icon.png" mode="widthFix" @click="isShowDialog = false"></image>
		</view>

		<view class="empty_data" v-if="isShowEmptyData">
			<view class="empty_data_content">
				<image class="empty_data_image" src="../../static/empty_data.png" mode="widthFix"></image>
				<view class="empty_data_title">暂无数据</view>
			</view>
		</view>
		<view v-else>
			<image src="../../static/home_banner.png" mode="widthFix"></image>
			<view class="menu_list">
				<view class="menu_item" @click="openBuilderPage">
					<view class="menu_item_icon"><image src="../../static/loupan_menu.png" mode="widthFix"></image></view>
					<view class="menu_item_title"><text>热改楼盘</text></view>
				</view>
				<view class="menu_item" @click="openComboPage">
					<view class="menu_item_icon"><image src="../../static/linbao_menu.png" mode="widthFix"></image></view>
					<view class="menu_item_title"><text>拎包入住</text></view>
				</view>
				<view class="menu_item" @click="openConstructionPage">
					<view class="menu_item_icon"><image src="../../static/gongdi_menu.png" mode="widthFix"></image></view>
					<view class="menu_item_title"><text>工地实景</text></view>
				</view>
				<view class="menu_item">
					<view class="menu_item_icon"><image src="../../static/baojie_menu.png" mode="widthFix"></image></view>
					<view class="menu_item_title"><text>保洁阿姨</text></view>
				</view>
			</view>
			<view>
				<view class="selection_content">
					<view class="header header_more">
						<view class="horizontal">
							<view class="line"></view>
							<view class="selection_header_title">热改楼盘</view>
						</view>
						<view class="horizontal" @click="openBuilderPage">
							<view class="more_text">更多</view>
							<view class="more_icon"></view>
						</view>
					</view>
					<view class="selection_content_list">
						<view class="selection_content_item" @click="openBuilderDetails(item.id)" v-for="(item, index) in buildList" :key="index">
							<view class="selection_content_item_image"><image :src="item.thumb" mode="scaleToFill"></image></view>
							<view class="selection_content_item_mark">
								<view class="selection_content_item_mark_title">{{ item.name }}</view>
								<view class="selection_content_item_mark_content">{{ item.model.name }}/{{ item.style.name }}</view>
							</view>
						</view>
					</view>
				</view>

				<view class="selection_content">
					<view class="header header_more">
						<view class="horizontal">
							<view class="line"></view>
							<view class="selection_header_title">拎包入住</view>
						</view>
						<view class="horizontal" @click="openComboPage">
							<view class="more_text">更多</view>
							<view class="more_icon"></view>
						</view>
					</view>
					<view class="selection_content_list">
						<view class="selection_content_item" v-for="(item, index) in comboList" :key="index">
							<view class="selection_content_item_image"><image :src="item.thumb" mode="scaleToFill"></image></view>
							<view class="selection_content_item_mark">
								<view class="selection_content_item_mark_title">{{ item.name }}</view>
								<view class="selection_content_item_mark_content">{{ item.model }}m²</view>
								<view class="selection_content_item_mark_content">{{ item.desc_str }}</view>
							</view>
						</view>
					</view>
				</view>

				<view class="selection_content">
					<view class="header header_more">
						<view class="horizontal">
							<view class="line"></view>
							<view class="selection_header_title">工地实景</view>
						</view>
						<view class="horizontal" @click="openConstructionPage">
							<view class="more_text">更多</view>
							<view class="more_icon"></view>
						</view>
					</view>
					<view class="selection_content_list">
						<view
							@click="openConstructionDetails(item.id)"
							class="selection_content_item"
							style="width: 520rpx;height: 312rpx;"
							v-for="(item, index) in constructionList"
							:key="index"
						>
							<view class="selection_content_item_image" style="width: 520rpx;height: 312rpx;"><image :src="item.thumb" mode="widthFix"></image></view>
							<view class="selection_content_item_mark" style="width: 520rpx;">
								<view class="selection_content_item_mark_title" style="text-align: center;">{{ item.name }}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			isShowDialog: true,
			isShowServeInfo: false,
			isShowEmptyData: false,
			buildList: [],
			comboList: [],
			constructionList: []
		};
	},
	onLoad() {
		uni.request({
			url: 'https://baiyi.kent.work/api/v1/system/getIndexData',
			method: 'GET',
			success: res => {
				if (res.data.code == 200) {
					this.isShowEmptyData = false;
					this.buildList = res.data.data.buildList;
					this.comboList = res.data.data.comboList;
					this.constructionList = res.data.data.constructionList;
				} else {
					this.isShowEmptyData = true;
				}
			},
			fail: e => {
				this.isShowEmptyData = true;
			}
		});
	},
	methods: {
		openBuilderPage() {
			uni.navigateTo({
				url: `/pages/index/builder/builder`
			});
		},
		openBuilderDetails(id) {
			uni.navigateTo({
				url: `/pages/index/builder/details/details?id=${id}`
			});
		},
		openComboPage() {
			uni.navigateTo({
				url: '/pages/index/combo/combo'
			});
		},
		openConstructionPage() {
			uni.navigateTo({
				url: '/pages/index/construction/construction'
			});
		},
		openConstructionDetails(id) {
			uni.navigateTo({
				url: `/pages/index/construction/details/details?id=${id}`
			});
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	background-color: #f5f5f5;
}
image {
	width: 100%;
}
::-webkit-scrollbar {
	display: none;
}
.content{
	padding-bottom: 112rpx;
}
.content_empty{
	padding-bottom: 112rpx;
}
.dialog {
	position: fixed;
	width: 100%;
	height: 100vh;
	background-color: rgba(0, 0, 0, 0.5);
	z-index: 999;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;

	.dialog_banner {
		width: 542rpx;
		height: 724rpx;
	}
	.dialog_close {
		margin-top: 86rpx;
		width: 80rpx;
		height: 80rpx;
	}
}
.serve {
	position: fixed;
	bottom: 132rpx;
	right: 20rpx;
	z-index: 999;

	.serve_image {
		width: 182rpx;
	}
	.serve_info {
		background: rgba(255, 255, 255, 0.8);
		border-radius: 12rpx;
		box-shadow: -4rpx 4rpx 4rpx 0rpx rgba(0, 0, 0, 0.15);
		padding-bottom: 40rpx;

		.header_more {
			padding: 20rpx;
		}
		.serve_info_contact {
			margin-left: 20rpx;
		}
		.serve_info_close {
			width: 44rpx;
		}
		.serve_info_list {
			.serve_info_item {
				display: flex;
				padding: 0 46rpx;
				margin-top: 20rpx;

				.serve_info_item_image {
					width: 44rpx;
				}
				.serve_info_item_contactNumber {
					margin-left: 40rpx;
					font-size: 28rpx;
				}
			}
		}
		.serve_info_item:first-child {
			margin-top: 32rpx;
		}
	}
}

.menu_list {
	display: flex;
	padding: 40rpx 0;

	.menu_item {
		flex-basis: 25%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		.menu_item_icon {
			width: 80rpx;
		}
		.menu_item_title {
			font-size: 24rpx;
		}
	}
}
.selection_content {
	padding: 28rpx 40rpx 28rpx 40rpx;
	background-color: white;
	margin-top: 40rpx;

	.selection_header_title {
		font-size: 28rpx;
		margin-left: 20rpx;
	}
	.more_text {
		font-size: 24rpx;
	}
	.more_icon {
		margin-left: 10rpx;
		width: 8rpx;
		height: 8rpx;
		border-left: 2rpx solid #333;
		border-top: 2rpx solid #333;
		transform: rotate(135deg);
	}

	.selection_content_list {
		display: flex;
		overflow-x: scroll;
		overflow-y: hidden;

		.selection_content_item {
			position: relative;
			width: 382rpx;
			height: 510rpx;
			margin-top: 20rpx;
			margin-left: 40rpx;

			.selection_content_item_image {
				width: 382rpx;
				height: 510rpx;
			}

			.selection_content_item_image image {
				width: 100%;
				height: 100%;
				border-radius: 16rpx;
			}

			.selection_content_item_mark {
				box-sizing: border-box;
				position: absolute;
				background-color: rgba(0, 0, 0, 0.3);
				border-bottom-left-radius: 16rpx;
				border-bottom-right-radius: 16rpx;
				bottom: 0;
				width: 382rpx;
				padding: 12rpx 24rpx;
				line-height: 1.2em;

				.selection_content_item_mark_title {
					font-size: 24rpx;
					color: white;
				}
				.selection_content_item_mark_content {
					margin-top: 8rpx;
					font-size: 20rpx;
					color: rgba(255, 255, 255, 0.7);
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
				}
			}
		}
		.selection_content_item:first-child {
			margin-left: 0;
		}
	}
}
.selection_content:first-child {
	margin-top: 0;
}
</style>
